-
Notifications
You must be signed in to change notification settings - Fork 88
Add in-place question shuffle feature (no more buffer clutter!) #188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MandalTuhin
wants to merge
11
commits into
kawre:master
Choose a base branch
from
MandalTuhin:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I have made changes to the questions ui.
This commit tries to fix the error shown by nvim when trying to shuffle questions.
This commit attempts to fix the random question functionality of leetcode.nvim. This puts the function at the bottom of the question.lua so that it doesn't interfere with other files.
This commit tries to reload the description buffer/panel with each shuffle to correctly represent the problem we are currently in.
Adds a new `:Leet shuffle` command that allows users to quickly load a new random problem in the current buffer. This feature mimics the behavior of the shuffle button on the LeetCode website, providing a seamless way to practice different problems without navigating back to the main menu or opening a new tab. The implementation includes: - A new `Question:shuffle()` method to handle fetching the new problem, updating the buffer state, and recreating the UI. - Correct buffer file path management (`nvim_buf_set_name`) to ensure state consistency and prevent saving work to the wrong file. - Proper unmounting and remounting of UI components (Description, Info, Console). fix(ui): resolve memory leak in console unmount Additionally, this commit fixes a memory leak in the console layout. The `unmount` function was incorrectly creating new UI popups instead of destroying the existing ones. This has been corrected to prevent orphaned windows from accumulating during operations like shuffling.
This commit addresses two follow-up issues discovered after the initial implementation of the question shuffle feature: 1. The `:Leet shuffle` command was not working due to a bug in the command parser that incorrectly handled single-word commands. The parser has been made more robust to correctly execute the command. 2. Shuffling a question caused LSP errors (e.g., from `clangd`) because the language server would not recognize the buffer's new file path. A `BufRead` autocommand is now triggered after shuffling to force the LSP to re-synchronize with the buffer.
This commit provides a definitive fix for LSP errors that occurred during a question shuffle. Previously, language servers like `clangd` could enter a confused state, resulting in "non-added document" errors. The root cause was that the LSP client was not properly detached before the buffer's underlying file path was changed. The new implementation resolves this by: - Explicitly stopping the active LSP client before any modifications. - Re-triggering LSP attachment via `BufRead` only after the shuffle is complete. This ensures a clean lifecycle for the LSP session, making the shuffle feature stable and error-free. q
A typo (`cmds1` instead of `cmds[1]`) was introduced in the command execution logic, causing a Lua error on startup and preventing the plugin from loading. This commit corrects the typo, restoring the plugin's functionality.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a “shuffle” feature to LeetCode.nvim, allowing users to load a new random question in the same buffer, with the question info panel updating as well. Previously, using the random feature would open a new buffer each time, requiring manual cleanup. Now, users can quickly browse random questions—just like the shuffle button on the LeetCode website!
Key changes:
Benefits:
I’d love feedback and am happy to make changes as needed!